class IUP_HBOX
-- Container for composing elements horizontally

inherit
	IUP_LINEAL_BOX
		redefine
			set_alignment,
			set_expand_children,
			set_size,
			set_raster_size
		end

create {ANY}
	hbox_empty,
   hbox

feature {ANY}

	hbox_empty
	   -- Create an empty hbox
		local
			p, a_hbox: POINTER
		do
			a_hbox := int_hbox_empty (p)
			set_widget(a_hbox)
		end
		
	hbox (col: ARRAY[IUP_WIDGET])
	   -- Create a new hbox containing the list of widgets
		local
         i: INTEGER; arg: ARRAY[POINTER]; s: IUP_WIDGET; a_hbox: POINTER
		do
			i := col.count

			create arg.make_filled(default_pointer, 1, i + 1)
			i := 0

			across
			   col as ic
	      loop
		      i := i + 1
            s := ic.item
            arg.put(s.widget, i)
		   end

			a_hbox := int_hbox (get_pointer(arg.to_c))
			set_widget(a_hbox)
		end

	-- Attributes

	set_alignment (value: STRING)
		-- (non inheritable): Vertically aligns the elements. Possible values: 
		-- "ATOP", "ACENTER", "ABOTTOM". Default: "ATOP".
		do
			Precursor (value)
		end

	set_expand_children (state: BOOLEAN)
		-- (non inheritable): forces all children to expand vertically and to 
		-- fully occupy its space available inside the box. Default: "NO". This 
		-- has the same effect as setting EXPAND=VERTICAL on each child.
		do
			Precursor (state)
		end

	set_size (width: INTEGER; height: INTEGER)
		-- (non inheritable): Defines the width of the box. Height will be
		-- ignored. When consulted behaves as the standard SIZE attribute.
		do
			Precursor (width, height)
		end

	set_raster_size (width: INTEGER; height: INTEGER)
		-- (non inheritable): Defines the width of the box. Height will be
		-- ignored. When consulted behaves as the standard RASTERSIZE attribute.
		do
			Precursor (width, height)
		end

	-- Validations

	is_valid_alignment (value: STRING): BOOLEAN
		do
			if value.is_equal("ATOP") or
				value.is_equal("ACENTER") or
				value.is_equal("ABOTTOM") then
				Result := True
			else
				Result := False
			end
		end
	
feature {NONE}

	-- Internals
	
	int_hbox_empty (arguments: POINTER): POINTER
		external
			"C inline use %"eiffel-iup.h%""
      alias
			"return IupHbox ($arguments);"
      end
	
   int_hbox (arguments: POINTER): POINTER
		external
			"C inline use %"eiffel-iup.h%""
      alias
			"return IupHboxv ($arguments);"
      end
	
end -- class IUP_HBOX

-- The MIT License (MIT)

-- Copyright (c) 2016, 2019, 2020 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
